package ArrayListDemo;

import java.util.ArrayList;

public class demo2 {
    public static void main(String[] args) {
        ArrayList <Student> list = new ArrayList<>();
        list.add(new Student("张三",18));
        list.add(new Student("李四",19));
        //集合和数组的区别:集合的长度是可变的,数组的长度是固定的
        System.out.println(list);
        for (Student student : list) {
            System.out.println(student.getName() + " " + student.getAge());
        }
    }
}
